Skip to content

Clarify useEffect behavior for empty dependency array#1990

Closed
ryancogswell wants to merge 1 commit into
reactjs:mainfrom
ryancogswell:patch-1
Closed

Clarify useEffect behavior for empty dependency array#1990
ryancogswell wants to merge 1 commit into
reactjs:mainfrom
ryancogswell:patch-1

Conversation

@ryancogswell
Copy link
Copy Markdown

The current wording "If you want to run an effect and clean it up only once (on mount and unmount), you can pass an empty array ([]) as a second argument." is confusing some people. They are interpreting this as meaning that the effect will run on mount and on unmount. See cbdev420's comment on my answer here.

The current wording "If you want to run an effect and clean it up only once (on mount and unmount), you can pass an empty array ([]) as a second argument." is confusing some people. They are interpreting this as meaning that the effect will run on mount **and** on unmount. See cbdev420's comment on my answer [here](https://stackoverflow.com/questions/56115295/how-to-set-up-an-event-listener-and-remove-it-after-first-fired-event-using-reac/56115564?noredirect=1#comment98864939_56115564).
@reactjs-bot
Copy link
Copy Markdown

Deploy preview for reactjs ready!

Built with commit 446da40

https://deploy-preview-1990--reactjs.netlify.com

@rickhanlonii
Copy link
Copy Markdown
Member

Sorry we missed this. Closing since we rewrote all of these docs, but if you see this issue still present in the new docs feel free to submit a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants